package cc.vv.btpartyjob.homepage.activity

import android.support.v4.app.Fragment
import android.support.v4.view.ViewPager
import android.view.View
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.homepage.R
import cc.vv.btpartyjob.homepage.delegate.WarningNoticeActivityDelegate
import cc.vv.btpartyjob.homepage.fragment.WarningLookNoFragment
import cc.vv.btpartyjob.homepage.fragment.WarningLookYesFragment
import cc.vv.btpartyjob.jnimodule.adapter.JniViewPageAdapter
import cc.vv.btpartyjob.jnimodule.binder.BaseBinder
import cc.vv.mvp.activity.BaseActivityMVP
import cc.vv.mvp.binder.BaseDataBinder

/**
 * 预警通知
 * Created by Chen.qi on 2018/10/27.
 */
class WarningNoticeReportActivity : BaseActivityMVP<WarningNoticeActivityDelegate>() {
    /**
     * ViewPager适配器
     */
    private var mAdapter: JniViewPageAdapter? = null
    /**
     * Fragment集合
     */
    private var mFragments: ArrayList<Fragment>? = null

    override fun initData() {
        viewDelegate?.setTopBarTitle("预警通知")
        mFragments = ArrayList()
        val registerYesFragment = WarningLookYesFragment()
        val registerNoFragment = WarningLookNoFragment()
        mFragments!!.add(registerYesFragment)
        mFragments!!.add(registerNoFragment)
        mAdapter = JniViewPageAdapter(supportFragmentManager, mFragments!!)
        viewDelegate?.setAdapterData(mAdapter!!)
        viewDelegate?.setRegisterYesSelect(true)
    }

    override fun bindEvenListener() {
        viewDelegate?.setTitleBackBtnOnClick(object : BaseTopBarView.EventInterface {
            //返回
            override fun leftOnClick() {
                finish()
            }

            override fun leftCloseClick() {}
            override fun rightOnClick() {
            }
        })

        viewDelegate?.setOnClickListener(View.OnClickListener {
            //已查看
            viewDelegate?.setRegisterYesSelect(true)
            viewDelegate?.setViewPagerPos(0)
        }, R.id.rl_awnL_lookYes)


        viewDelegate?.setOnClickListener(View.OnClickListener {
            //未查看
            viewDelegate?.setRegisterYesSelect(false)
            viewDelegate?.setViewPagerPos(1)
        }, R.id.rl_awnL_lookNo)

        viewDelegate?.bindViewPagerLisener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {
            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }

            override fun onPageSelected(position: Int) {
                if (position == 0) {
                    viewDelegate?.setRegisterYesSelect(true)
                } else {
                    viewDelegate?.setRegisterYesSelect(false)
                }
            }
        })
    }

    override fun getDelegateClass(): Class<WarningNoticeActivityDelegate> {
        return WarningNoticeActivityDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }
}